package socket;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.util.Scanner;

public class Rec {
    public static void main(String[] args) throws IOException {
        Socket soc=null;
        InputStream is=null;

        try {
            byte[] b=new byte[1024];
            soc =new Socket("127.0.0.1",81);
            is=soc.getInputStream();//获得输入流
            int s=is.read(b);
            System.out.println(new String(b,0,s));

        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (soc!=null){
                try{soc.close();}catch (IOException e){
                    if (is!=null){ is.close();}
                }
            }

        }
    }

}
